package com.pdstudio.carrecom.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.pdstudio.carrecom.R;
import com.pdstudio.carrecom.bean.HomeInfo;
import com.pdstudio.carrecom.bean.Order;

import java.util.List;

/**
 * 
 * 类: MyOrderListAdapter <br>
 * 描述: 我的订单适配器 <br>
 * 作者: ws  <br>
 * 时间: 2015-6-15 下午11:22:35
 */
public class MyOrderListAdapter extends BaseAdapter {

    private Context mContext;
    private List<Order> mOrders;
    private LayoutInflater mInflater;

    public MyOrderListAdapter(Context context, List<Order> orders) {
        mContext = context;
        mOrders = orders;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mOrders.size();
    }

    @Override
    public Object getItem(int i) {
        return mOrders.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder;

        if (view == null) {
            viewHolder = new ViewHolder();
            view = mInflater.inflate(R.layout.item_listview_orders, viewGroup, false);
            viewHolder.mTitle = (TextView) view.findViewById(R.id.news_title);

            view.setTag(viewHolder);
        } else {
          viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.mTitle.setText(mOrders.get(i).getTitle());

        return view;
    }


    class ViewHolder {
        private TextView mTitle;
        private TextView mName;
        private TextView mPrice;
        private TextView mNumber;
    }
}
